<template>
	<view class="content">
		<view class="mix-list-cell" :class="border" @click="eventClick" hover-class="cell-hover" :hover-stay-time="50">
			<!-- 图标 -->
			<text v-if="icon" class="cell-icon iconfont " :style="[{
					color: iconColor,
				}]" :class="icon"></text>
			<text v-if="tIcon" class="cell-icon t-icon " :class="tIcon"></text>
			<view style="flex-grow:3;display: flex;" :class="[showBorder?'v-border-bottom':'']">
				<!-- 标题 -->
				<text class="cell-tit">{{title}}</text>
				<!-- 描述 -->
				<text v-if="tips" class="cell-tip">{{tips}}</text>
				<view v-if="cellType=='input'">
					<slot />
				</view>
			</view>
			<!-- 更多 -->
			<text class="cell-more iconfont" :class="typeList[navigateType]"></text>
		</view>

	</view>
</template>

<script>
	/**
	 *  简单封装了下， 应用范围比较狭窄，可以在此基础上进行扩展使用
	 *  比如加入image， iconSize可控等
	 */
	export default {
		data() {
			return {
				typeList: {
					left: 'iconarrow-left-bold',
					right: 'iconarrow-right',
					more: 'iconmore',
					help: 'iconhelp'
				},
			}
		},
		props: {
			cellType:{
				type:String,
				default:'text'
			},
			// 是否显示下划线
			showBorder: {
				type: Boolean,
				default: true
			},
			//设置前边显示的图标
			icon: {
				type: String,
				default: ''
			},
			//设置插图
			tIcon: {
				type: String,
				default: ''
			},
			//设置标题
			title: {
				type: String,
				default: '标题'
			},
			//设置描述
			tips: {
				type: String,
				default: ''
			},

			/**
			 * 设置右侧图标
			 * left/right/more/help
			 */
			navigateType: {
				type: String,
				default: ''
			},
			border: {
				type: String,
				default: 'b-b'
			},
			hoverClass: {
				type: String,
				default: 'cell-hover'
			},
			iconColor: {
				type: String,
				default: '#333'
			}
		},
		methods: {
			eventClick() {
				this.$emit('eventClick');
			}
		},
	}
</script>

<style lang='scss' scoped>
	.v-border-bottom {
		border-bottom: 0.5rpx solid #e5e5e5;
	}

	.icon .mix-list-cell.b-b:after {
		left: 90upx;
	}

	.cell-hover {
		background: #fafafa;
	}

	.b-b:after {
		left: 30upx;
	}

	.mix-list-cell {
		display: flex;
		align-items: center;
		padding: 0 30rpx;
		background-color: #FFFFFF;
		line-height: 100rpx;
	}

	.cell-icon {
		align-self: center;
		font-size: 38rpx;
		margin-right: 18rpx;
	}

	.cell-more {
		align-self: center;
		font-size: 32rpx;
		color: #999999;
	}

	.cell-tit {
		flex: 1;
		font-size: 32rpx;
		color: #1E1E1E;
		margin-right: 10upx;
	}

	.cell-tip {
		font-size: 28rpx;
		color: #999999;
		max-width: 440rpx;
		display: inline-block;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
</style>
